//
//  AboutUSViewController.m
//  SsehMaster
//
//  Created by yang yang on 2018/8/15.
//  Copyright © 2018年 yinlong. All rights reserved.
//

#import "AboutUSViewController.h"
#import "SsehConfigModel.h"
#import "SsehSettingTableViewCell.h"
#import "UserAgreementViewController.h"


@interface AboutUSViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic,strong) UITableView * tableView;

@property (nonatomic,strong) NSMutableArray * dataSource;

@end

static NSString * const SsehSettingTableViewCellID = @"SsehSettingTableViewCellID";

@implementation AboutUSViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"关于我们";
    [self layoutUI];
}


- (void)layoutUI{
    
    self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(5, NAVIGATION_BAR_HEIGHT, F_DEVICE_W-10,F_DEVICE_H-NAVIGATION_BAR_HEIGHT-bottomPadding(0)) style:UITableViewStylePlain];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.layer.cornerRadius = 5;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView.showsVerticalScrollIndicator = NO;
    self.tableView.showsHorizontalScrollIndicator = NO;
    self.tableView.backgroundColor = [UIColor whiteColor];
    [self.tableView registerNib:[UINib nibWithNibName:@"SsehSettingTableViewCell" bundle:nil] forCellReuseIdentifier:SsehSettingTableViewCellID];
    [self.view addSubview:self.tableView];
    
    UIView * headerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, F_DEVICE_W-10, (F_DEVICE_H-100-NAVIGATION_BAR_HEIGHT)/2)];
    headerView.backgroundColor = [UIColor whiteColor];
    self.tableView.tableHeaderView = headerView;
    
    UIImageView * logoImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"ssehLogo"]];
    [headerView addSubview:logoImageView];
    [logoImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.centerY.equalTo(headerView);
        make.size.mas_equalTo(CGSizeMake(105*PROPORTION_WIDTH_IPHONE6, 105*PROPORTION_WIDTH_IPHONE6));
    }];
    UIImageView * titleImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"logo_word"]];
    [headerView addSubview:titleImageView];
    [titleImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.equalTo(logoImageView);
        make.top.equalTo(logoImageView.mas_bottom).offset(5);
        make.size.mas_equalTo(CGSizeMake(84*PROPORTION_WIDTH_IPHONE6, 23*PROPORTION_HEIGHT_IPHONE6));
    }];
    
    UIView * footerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, F_DEVICE_W-10, (F_DEVICE_H-100-NAVIGATION_BAR_HEIGHT)/2)];
    footerView.backgroundColor = [UIColor whiteColor];
    self.tableView.tableFooterView = footerView;
    
    
    UILabel * ssehTLabel = [UILabel new];
    ssehTLabel.textColor = RGBColor(153, 153, 153);
    ssehTLabel.font = [UIFont systemFontOfSize:12];
    ssehTLabel.text = @"Copyright © 1998 - 2020 一步e家 版权所有";
    ssehTLabel.textAlignment = NSTextAlignmentCenter;
    [footerView addSubview:ssehTLabel];
    [ssehTLabel mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.centerX.equalTo(footerView);
        make.bottom.equalTo(footerView).offset(-bottomPadding(10));
        
    }];
    
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.dataSource.count;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return 50;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    UserAgreementViewController *userAgreeVC = [[UserAgreementViewController alloc]init];
    TAB_PUSH(self, userAgreeVC, YES);
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    SsehSettingTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:SsehSettingTableViewCellID];
    
    SsehConfigModel * model = self.dataSource[indexPath.row];
    [cell configData:model andIndex:indexPath];
    
    return cell;
    
}


-(NSMutableArray *)dataSource{
    if (_dataSource == nil) {
        _dataSource = [[NSMutableArray alloc]initWithCapacity:0];
        SsehConfigModel * model = [[SsehConfigModel alloc]init];
        model.titleStr = @"用户注册服务协议";
        model.imageName = @"rightshap";
        model.vcName = @"";
        [_dataSource addObject:model];
    }
    return _dataSource;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
